//
//  JMPhotosManager.h
//  ImagePicker
//
//  Created by Jamin on 2018/10/15.
//  Copyright © 2018 jamin. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <Photos/Photos.h>
#import "JMIPAlbum.h"
#import "JMIPAsset.h"
@interface JMPhotosManager : NSObject

@property (nonatomic, class, readonly) __kindof JMPhotosManager *manager;

@property (nonatomic, class) BOOL notScaleImage;

+ (BOOL)authorizationStatusAuthorized;
+ (void)requestAuthorization:(void(^)())completion;
+ (void)getAlbumListWithcompletion:(void(^)(NSArray <JMIPAlbum *>*albums))completion;


+ (void)getAssetsFromFetchResult:(PHFetchResult *)result
                      completion:(void (^)(NSArray<JMIPAsset *> *assets))completion;
+ (void)getAssetsFromFetchResult:(PHFetchResult *)result
                      allowVideo:(BOOL)allowVideo
                      allowImage:(BOOL)allowImage
                      completion:(void (^)(NSArray<JMIPAsset *> *assets))completion;
///  Get asset at index 获得下标为index的单个照片
///  if index beyond bounds, return nil in callback 如果索引越界, 在回调中返回 nil
+ (void)getAssetFromFetchResult:(PHFetchResult *)result
                        atIndex:(NSInteger)index
                     allowImage:(BOOL)allowImage
                     completion:(void (^)(JMIPAsset *asset))completion;

+ (void)getAblumThumbnailImage:(JMIPAlbum *)album completion:(void (^)(UIImage *image))completion;


+ (int32_t)getPhotoWithAsset:(PHAsset *)asset
                  photoWidth:(CGFloat)photoWidth
                  completion:(void (^)(UIImage *photo, NSDictionary *info, BOOL isDegraded))completion;


+ (int32_t)getPhotoWithAsset:(PHAsset *)asset
                  photoWidth:(CGFloat)photoWidth
                  completion:(void (^)(UIImage *photo,NSDictionary *info,BOOL isDegraded))completion
             progressHandler:(void (^)(double progress, NSError *error, BOOL *stop, NSDictionary *info))progressHandler
        networkAccessAllowed:(BOOL)networkAccessAllowed;




@end
